package cheme.ProcessModel.Cmds;

import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.commands.Command;

import cheme.ProcessModel.IParent;
import cheme.ProcessModel.Subprocess.ISubprocess;


public class CreateSubprocessCmd extends Command
{
	IParent parent;
	ISubprocess newSubprocess;
	Rectangle bounds;
	
	public CreateSubprocessCmd(ISubprocess newSubprocess, IParent parent, Rectangle bounds)
	{
		this.parent = parent;
		this.bounds = bounds;
		this.newSubprocess = newSubprocess;
	}
	
	public void execute()
	{
		/*
		 * Note that all children are required to hail form the same parent. 
		 */
		
		newSubprocess.setBounds(bounds);
		parent.add(newSubprocess);
	}

	public void undo()
	{
		parent.remove(newSubprocess);
	}
	
	@Override
	public void redo()
	{
		parent.add(newSubprocess);
	}
}
